public class java_0000_test {

    static Object object = new Object();

    public static void main(String[] args) {



        Thread thread1 = new TheThread();
        Thread thread2 = new TheThread();

        thread1.start();
        thread2.start();
    }
}
class TheThread extends Thread {

    static Object object = new Object();

    static int sign = 1;

    @Override
    public void run() {
        while (sign < 1000) {
            synchronized (object) {
                for (int i=0; i<5; i++) {
                    System.out.println(Thread.currentThread().getName() + "---" + sign++);
                }
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}
